﻿#region [GUI Using Statements]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Input;
using WP7_XNA_Accelerometer_Simulator.Utils;
using WP7_XNA_Accelerometer_Simulator.GameObjects.MovementControls;
using WP7_XNA_Accelerometer_Simulator.GameObjects.SuperClasses;
using WP7_XNA_Accelerometer_Simulator.GameObjects.GameModels;
using Microsoft.Xna.Framework;
#endregion

namespace WP7_XNA_Accelerometer_Simulator.Utils.GameInfo
{
    /// <summary>
    /// This Class provides access to elements drawn in the game
    /// </summary>
    public static class GUI
    {
        #region [GUI Properties]
        public static List<GameObject3D> GameObjects3D { get; set; }
        #endregion

        #region [GUI Public Methods]
        /// <summary>
        /// Creates all the models needed to use the simulator
        /// </summary>
        /// <remarks>
        /// It will also upload the initial acceleration and rotation
        /// values to the server
        /// </remarks>
        public static void CreateSimulatorEnvironment()
        {
            GameObjects3D = new List<GameObject3D>();
            WindowsPhone wp7 = new WindowsPhone();
            GameObjects3D.Add(wp7);
            GameObjects3D.Add(new PitchRollControl());
            GameObjects3D.Add(new YawControl());
            GameObjects3D.Add(new Axis());

            UploadInitialValues(wp7);
        }
        #endregion

        #region [GUI Private Methods]
        /// <summary>
        /// Uploads the initial acceleration and rotation values to the server
        /// </summary>
        /// <param name="wp7">The WindowsPhone from which to get the values </param>
        private static void UploadInitialValues(WindowsPhone wp7)
        {
            Vector3 accelValues = wp7.GetAccelValues();
            Vector3 rotValues = wp7.Rotation;
            GameManager.AccelerometerService.UploadAccelData(accelValues.X,
                                                                accelValues.Y,
                                                                accelValues.Z);
            GameManager.AccelerometerService.UploadRotationData(rotValues.X,
                                                                rotValues.Y,
                                                                rotValues.Z);
        }
        #endregion
    }
}
